package cn.wolfcode.p2p.mgrsite.controller;


import cn.wolfcode.p2p.base.excetion.DisplayableExcetion;
import cn.wolfcode.p2p.base.query.PlatformBankInfoQueryObject;
import cn.wolfcode.p2p.base.util.AjaxResult;
import cn.wolfcode.p2p.bussness.domain.PlatformBankInfo;
import cn.wolfcode.p2p.bussness.service.IPlatformBankInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * 平台账户管理
 */
@Controller
public class PlatformBankInfoController {
    @Autowired
    private IPlatformBankInfoService platformBankInfoService;
    /**
     * 管理列表
     */
    @RequestMapping("/companyBank_list")
    public String platformBankInfoList(@ModelAttribute("qo") PlatformBankInfoQueryObject qo, Model model){
        model.addAttribute("pageInfo",platformBankInfoService.queryPage(qo));
        return "platformbankinfo/list";
    }
    /**
     * 保存和更新
     */
    @RequestMapping("/companyBank_update")
    @ResponseBody
    public AjaxResult saveOrUpdate(PlatformBankInfo platformBankInfo){
        AjaxResult result = null;
        try{
            platformBankInfoService.saveOrUpdate(platformBankInfo);
            result = new AjaxResult();
        }catch(DisplayableExcetion e){
            e.printStackTrace();
            result = new AjaxResult(false,e.getMessage());
        }catch(Exception e){
            e.printStackTrace();
            result = new AjaxResult(false,"系统异常,请联系管理员!");
        }
        return result;
    }
}
